<?php

/**
 * API：Restful模块
 */

namespace app\controller\api;

use app\BaseController;
use think\facade\Db;

class Restful extends BaseController
{
    //get请求-列表
    public function list()
    {
        $data = [
            'url' => request()->url(),
            'method'=>request()->method(),
            'name' => request()->param('name'),
            'age' => request()->param('age'),
        ];
        return json($data);
    }

    //get请求-详情
    public function detail($id)
    {
        $data = [
            'url' => request()->url(),
            'method'=>request()->method(),
            'id' => $id,
        ];
        return json($data);
    }

    //post请求
    public function add()
    {
        $data = [
            'url' => request()->url(),
            'method'=>request()->method(),
            'name' => request()->param('name'),
            'age' => request()->param('age'),
        ];
        return json($data);
    }

    //put请求
    public function update()
    {
        $data = [
            'url' => request()->url(),
            'method'=>request()->method(),
            'name' => request()->param('name'),
            'age' => request()->param('age'),
        ];
        return json($data);
    }

    //delete请求
    public function delete($id)
    {
        $data = [
            'url' => request()->url(),
            'method'=>request()->method(),
            'id' => $id,
        ];
        return json($data);
    }
}
